package com.cmsr.hdpf.util

import com.cmsr.hdpf.constant
import com.typesafe.config.ConfigFactory

object ConfigHelper {
    private lazy val defaultConfig = ConfigFactory.parseResources("conf/default.conf")
//    private lazy val environmentConfig = ConfigFactory.parseResources("conf/" + constant.env + ".conf") # 无 env 成员 -> 注释掉
    private lazy val userConfig = ConfigFactory.parseResources("application.conf")
    private lazy val config = ConfigFactory.load()
            .withFallback(userConfig)
//            .withFallback(environmentConfig)
            .withFallback(defaultConfig)
            .resolve()
    
    
    // 数据解析部分
    // 从kafka中获取原始数据
    val parse_source_kafka_bootstrapServers = config.getString("parse.source.kafka.bootstrap.servers")
    val parse_source_kafka_enableAutoCommit = config.getString("parse.source.kafka.enable.auto.commit")
    val parse_source_kafka_autoCommitIntervalMs = config.getString("parse.source.kafka.auto.commit.interval.ms")
    val parse_source_kafka_autoOffsetReset = config.getString("parse.source.kafka.auto.offset.reset")
    val parse_source_kafka_topic_raw_traffic = config.getString("parse.source.kafka.topic.row.traffic") // 解析的目标topic

    // 解析数据保存到hdfs中
    val datalake = config.getString("parse.source.hdfs.datalake")

    // 解析数据保存到kafka中
    val parse_sink_kafka_bootstrapServers = config.getString("parse.sink.kafka.bootstrap.servers")
    val parse_sink_kafka_enableAutoCommit = config.getString("parse.sink.kafka.enable.auto.commit")
    val parse_sink_kafka_autoCommitIntervalMs = config.getString("parse.sink.kafka.auto.commit.interval.ms")
    val parse_sink_kafka_autoOffsetReset = config.getString("parse.sink.kafka.auto.offset.reset")
    val parse_sink_kafka_topic_rsm = config.getString("parse.sink.kafka.topic.rsm") // 解析的目标写入的topic

    
    //时间窗口配置
    val windowDuration: Int = config.getInt("window.duration.seconds")
    val windowTimeStep: Int = config.getInt("window.step.seconds")
    
}
